package com.lingjtx.common.core.handle;

public class PooledObject<T> implements AutoCloseable {

    private final T object;
    private final ObjectPool<T> pool;

    public PooledObject(T object, ObjectPool<T> pool) {
        this.object = object;
        this.pool = pool;
    }

    public T get() {
        return object;
    }

    @Override
    public void close() {
        pool.release(object); // 自动释放
    }
}
